<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let age = 0;
        let arr = [];
        let num = 0;

        do {
            age = prompt(`请输入第${num + 1}个有效年龄(0-100之间)`)
            if (age >= 0 && age <= 100) {
                arr.push(age);
                num++;
            } else {
                alert('无效年龄')
            }
        }
        while (num !== 5)
        let chengnian = []
        let a = 18
        for (i = 0; i < arr.length; i++) {
            if (arr[i] >= a) {
                chengnian.push(arr[i])
            }
        }
        document.write(`成年人年龄:${chengnian}<br>`)

        let sum = 0
        for (let j = 0; j < arr.length; j++) {
            sum += +arr[j]
        }
        document.write(`加和：${sum}<br>`)
        let max = arr[0]
        let min = arr[0]
        for (let i = 0; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i]
            }
            if (arr[i] < min) {
                min = arr[i]
            }
        }
        document.write(`最大值${max}<br>`)
        document.write(`最小值${min}<br>`)
    </script>
</body>

</html>